import { LoginParams, UserInfo } from "@/type/login";
import axios, { Response } from "./axios";
import factorySingleClass from "./SingleClass";

class LoginServie {
    login(obj: LoginParams) {
        return axios.post<
            Response<{ access_token: string; expires_in: number }>
        >(`/usersys-app/login/phone`, obj);
    }
    // login(obj: LoginParams) {
    //     return axios.post<
    //         Response<{ access_token: string; expires_in: number }>
    //     >(`/usersys-app/login/password`, obj);
    // }
    getUserInfo() {
        return axios.get<Response<UserInfo>>(`/usersys-auth/user/login_info`);
    }
    logout() {
        return axios.get(`/usersys-app/sass/logout`);
    }
    getMenu() {
        return axios.get<Response<any[]>>(
            `/usersys-auth/sass/user/function_authority`,
        );
    }
    code(phone: string) {
        return axios.get(`/usersys-app/login/phone/code?phone=${phone}`);
    }
}

export default factorySingleClass(LoginServie);
